//
//  GQHSlideView.h
//  GQHKit
//
//  Created by GuanQinghao on 13/12/2017.
//  Copyright © 2017 GuanQinghao. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef enum {
    
    GQHPageControlAlignmentLeft,       // 分页控件居左
    GQHPageControlAlignmentCenter,     // 分页控件居中
    GQHPageControlAlignmentRight       // 分页控件居右
} GQHPageControlAlignment;

typedef enum {
    
    GQHPageControlStyleClassic,        // 系统自带经典样式
    GQHPageControlStyleAnimated,       // 动画效果
    GQHPageControlStyleNone            // 无效果
} GQHPageControlStyle;

@class GQHSlideView;
@protocol GQHSlideViewDelegate <NSObject>

@optional
// 点击回调
- (void)qh_slideView:(GQHSlideView *)slideView didSelectItemAtIndex:(NSInteger)index;
// 滚动回调
- (void)qh_slideView:(GQHSlideView *)slideView didScrollToIndex:(NSInteger)index;

// 自定义轮播图cell类
- (Class)qh_customCollectionViewCellClassForSlideView:(GQHSlideView *)slideView;
// 自定义轮播图cell的Nib
- (UINib *)qh_customCollectionViewCellNibForSlideView:(GQHSlideView *)slideView;
// 自定义轮播图cell填充数据及其他设置
- (void)qh_setupCustomCell:(UICollectionViewCell *)cell forIndex:(NSInteger)index slideView:(GQHSlideView *)slideView;

@end


@interface GQHSlideView : UIView

// 创建轮播图
+ (instancetype)qh_slideViewWithFrame:(CGRect)frame delegate:(id<GQHSlideViewDelegate>)delegate placeholderImage:(UIImage *)placeholderImage;

+ (instancetype)qh_slideViewWithFrame:(CGRect)frame imageURLArray:(NSArray *)imageURLArray;

+ (instancetype)qh_slideViewWithFrame:(CGRect)frame imageArray:(NSArray *)imageArray;

+ (instancetype)qh_slideViewWithFrame:(CGRect)frame loop:(BOOL)endless imageArray:(NSArray *)imageArray;

// 清除图片缓存
+ (void)qh_clearImageCache;

// 滚动控制
- (void)qh_slideView:(GQHSlideView *)slideView scrollToIndex:(NSInteger)index;
- (void)qh_adjustWhenViewWillAppear;

// 禁用手势
- (void)qh_disableScrollGesture;


// 数据源
@property (nonatomic, strong) NSArray *qh_imageArray;// image or imageName or imagePath
@property (nonatomic, strong) NSArray *qh_imageURLArray;// imageURL or imageURLString
@property (nonatomic, strong) NSArray *qh_textArray;

// 轮播属性
@property (nonatomic, assign) CGFloat qh_timeInterval;
@property (nonatomic, assign) BOOL qh_endless;
@property (nonatomic, assign) BOOL qh_autoScroll;
@property (nonatomic, assign) UICollectionViewScrollDirection qh_scrollDirection;

@property (nonatomic, weak) id<GQHSlideViewDelegate> qh_delegate;

// 点击监听
@property (nonatomic, copy) void (^selectItemMonitorBlock)(NSInteger index);
// 滚动监听
@property (nonatomic, copy) void (^scrollToItemMonitorBlock)(NSInteger index);

// 自定义样式
@property (nonatomic, assign) UIViewContentMode qh_slideViewContentMode;
@property (nonatomic, strong) UIImage *qh_placeholderImage;
@property (nonatomic, assign) BOOL qh_showPageControl;
@property (nonatomic, assign) BOOL qh_hidesForSinglePage;
@property (nonatomic, assign) BOOL qh_onlyText;

@property (nonatomic, assign) GQHPageControlStyle qh_pageControlStyle;
@property (nonatomic, assign) GQHPageControlAlignment qh_pageControlAlignment;


@property (nonatomic, assign) CGFloat qh_pageControlOffsetLeft;
@property (nonatomic, assign) CGFloat qh_pageControlOffsetRight;
@property (nonatomic, assign) CGFloat qh_pageControlOffsetBottom;
@property (nonatomic, assign) CGSize qh_pageControlDotSize;

@property (nonatomic, strong) UIColor *qh_pageDotColor;
@property (nonatomic, strong) UIColor *qh_currentPageDotColor;

@property (nonatomic, strong) UIImage *qh_pageDotImage;
@property (nonatomic, strong) UIImage *qh_currentPageDotImage;

@property (nonatomic, strong) UIColor *qh_titleLabelTextColor;
@property (nonatomic, strong) UIFont *qh_titleLabelTextFont;
@property (nonatomic, strong) UIColor *qh_titleLabelBackgroundColor;
@property (nonatomic, assign) CGFloat qh_titleLabelHeight;
@property (nonatomic, assign) NSTextAlignment qh_titleLabelTextAlignment;

@end
